﻿using BasicInformation.API.Application.Command.LineCommand;
using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace BasicInformation.API.Controllers
{
    /// <summary>
    /// 线路管理
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class LineController : ControllerBase
    {
        private readonly IMediator mediator;

        public LineController(IMediator mediator)
        {
            this.mediator = mediator;
        }
        /// <summary>
        /// 线路新增
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<int> LineAdd(LineCreateCommand command)
        {
            return await mediator.Send(command);
        }
        /// <summary>
        /// 线路删除
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpDelete]
        public async Task<int> LineDelete([FromQuery]LineDeleteCommand command)
        {
            return await mediator.Send(command);
        }
        /// <summary>
        /// 线路批量删除
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpDelete]
        public async Task<int> LineBatchDelete([FromQuery]LineBatchDeleteCommand command)
        {
            return await mediator.Send(command);
        }

        /// <summary>
        /// 线路修改
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpPut]
        public  async Task<int> LineUpdate(LineUpdateCommand command)
        {
            return await mediator.Send(command);
        }

    }
}
